package com.ruoyi.fee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fee.domain.WOverdueFeeRule;
import com.ruoyi.fee.service.IWOverdueFeeRuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 超期费Controller
 * 
 * @author wzy
 * @date 2024-08-30 11:41:37
 */
@RestController
@RequestMapping("/fees/overdue")
public class WOverdueFeeRuleController extends BaseController
{
    @Autowired
    private IWOverdueFeeRuleService wOverdueFeeRuleService;

    /**
     * 查询超期费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:overdue:list')")
    @GetMapping("/list")
    public TableDataInfo list(WOverdueFeeRule wOverdueFeeRule)
    {
        startPage();
        List<WOverdueFeeRule> list = wOverdueFeeRuleService.selectWOverdueFeeRuleList(wOverdueFeeRule);
        return getDataTable(list);
    }

    /**
     * 导出超期费列表
     */
    @PreAuthorize("@ss.hasPermi('fees:overdue:export')")
    @Log(title = "超期费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WOverdueFeeRule wOverdueFeeRule)
    {
        List<WOverdueFeeRule> list = wOverdueFeeRuleService.selectWOverdueFeeRuleList(wOverdueFeeRule);
        ExcelUtil<WOverdueFeeRule> util = new ExcelUtil<WOverdueFeeRule>(WOverdueFeeRule.class);
        util.exportExcel(response, list, "超期费数据");
    }

    /**
     * 获取超期费详细信息
     */
    @PreAuthorize("@ss.hasPermi('fees:overdue:query')")
    @GetMapping(value = "/{overdueFeeId}")
    public AjaxResult getInfo(@PathVariable("overdueFeeId") Long overdueFeeId)
    {
        return success(wOverdueFeeRuleService.selectWOverdueFeeRuleByOverdueFeeId(overdueFeeId));
    }

    /**
     * 新增超期费
     */
    @PreAuthorize("@ss.hasPermi('fees:overdue:add')")
    @Log(title = "超期费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WOverdueFeeRule wOverdueFeeRule)
    {
        wOverdueFeeRule.setCreateBy(getNickName());
        return toAjax(wOverdueFeeRuleService.insertWOverdueFeeRule(wOverdueFeeRule));
    }

    /**
     * 修改超期费
     */
    @PreAuthorize("@ss.hasPermi('fees:overdue:edit')")
    @Log(title = "超期费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WOverdueFeeRule wOverdueFeeRule)
    {
        wOverdueFeeRule.setUpdateBy(getNickName());
        return toAjax(wOverdueFeeRuleService.updateWOverdueFeeRule(wOverdueFeeRule));
    }

    /**
     * 删除超期费
     */
    @PreAuthorize("@ss.hasPermi('fees:overdue:remove')")
    @Log(title = "超期费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{overdueFeeIds}")
    public AjaxResult remove(@PathVariable Long[] overdueFeeIds)
    {
        return toAjax(wOverdueFeeRuleService.deleteWOverdueFeeRuleByOverdueFeeIds(overdueFeeIds));
    }
}
